package yws01.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import yws01.Business.*;
import yws01.Model.*;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
public class StationController {

    int yonghukahao;int yonghubianhao;String yonghumima;
    SaleServiceCheka serviceCheka;
    SaleServiceChewei serviceChewei;
    SaleServiceCheweifenpei serviceCheweifenpei;
    SaleServiceChezhu serviceChezhu;
    SaleServiceDongtaichewei serviceDongtaichewei;
    SaleServiceFeiwang serviceFeiwang;
    public long shijian(String x) throws ParseException {
        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date end=dfs.parse(x);
        java.util.Date  begin= dfs.parse("2019-01-01 00:00:00");
        long between=(end.getTime()-begin.getTime())/1000;
        System.out.println(between);
        return between;
    }
    @Autowired
    public void setServiceCheka(SaleServiceCheka serviceCheka) {
        this.serviceCheka = serviceCheka;
    }
    @Autowired
    public void setServiceChewei(SaleServiceChewei serviceChewei) {
        this.serviceChewei = serviceChewei;
    }
    @Autowired
    public void setSaleServiceCheweifenpei(SaleServiceCheweifenpei serviceCheweifenpei) {
        this.serviceCheweifenpei = serviceCheweifenpei;
    }
    @Autowired
    public void setServiceChezhu(SaleServiceChezhu serviceChezhu) {
        this.serviceChezhu = serviceChezhu;
    }
    @Autowired
    public void setServiceDongtaichewei(SaleServiceDongtaichewei serviceDongtaichewei) {
        this.serviceDongtaichewei = serviceDongtaichewei;
    }
    @Autowired
    public void setServiceFeiwang(SaleServiceFeiwang serviceFeiwang) {
        this.serviceFeiwang = serviceFeiwang;
    }
    @RequestMapping(value = "/index.html")
    public String index(){
        return "index";
    }
    @RequestMapping(value = "denglushibai.html")
    public String denglushibai(){return "denglushibai";}
    @RequestMapping(value="loginyonghu.html")
    public String loginyonghu(){return "loginyonghu";}
    @RequestMapping(value = "loginguanli.html")
    public String loginguanli(){return "loginguanli";}
    @RequestMapping(value = "loginzhuce.html")
    public String loginzhuce(){return "loginzhuce";}
    @RequestMapping(value = "logincheckyonghu.html")
            public String logincheckyonghu(HttpServletRequest request,Chezhu chezhu) throws ParseException {
            Chezhu xx=new Chezhu();
            System.out.println(chezhu.chezhubianhao+" "+chezhu.getMima());
            xx.setChezhubianhao(chezhu.getChezhubianhao());
            Chezhu chezhu1=serviceChezhu.Chezhuquery(xx);
            String x1="VIP";
            if(chezhu1.getChezhuleixing().equals(x1))
            {
                yonghubianhao=chezhu1.getChezhubianhao();
                yonghumima=chezhu1.getMima();
                yonghukahao=chezhu1.getChekabianhao();
                Chezhu chezhu2=new Chezhu();chezhu2.setChezhubianhao(yonghubianhao);
                Chezhu chezhu3=serviceChezhu.Chezhuquery(chezhu2);long x=shijian(chezhu1.getVipshijian());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String date= format.format(new Date());long y=shijian(date);
                int dd=(int)(31536000-y+x)/86400;int hh=(int)((31536000-y+x)%86400)/3600;
                String sum=dd+"天"+hh+"小时";chezhu3.setVipshijian(sum);
                System.out.println(chezhu1.getVipshijian());
                request.getSession().setAttribute("chezhu3s",chezhu3);
                return "vipdenglu";}
            else if(chezhu1.getMima().equals(chezhu.mima))
            {
                yonghubianhao=chezhu1.getChezhubianhao();
                yonghumima=chezhu1.getMima();
                yonghukahao=chezhu1.getChekabianhao();
                return "yonghuzhuyemian";
        }
        return "denglushibai";
    }
    @RequestMapping(value = "logincheckguanli.html")
    public String logincheckguanli(){return "logincheckguanli";}
    @RequestMapping(value = "yonghuzhuyemian.html")
    public String yonghuzhuyemian(){return "yonghuzhuyemian";}
    @RequestMapping(value = "guanliyuanzhuyemian.html")
    public String guanliyuanzhuyemian(){return "guanliyuanzhuyemian";}
    @RequestMapping(value = "zhuce.html")
    public String zhuce(HttpServletRequest request, Chezhu chezhu){
        if(serviceChezhu.Chezhuquery(chezhu)==null)
        {
            SimpleDateFormat format = new SimpleDateFormat("yyMMHHmmss");
            String date= format.format(new Date());
            int b = Integer.valueOf(date).intValue();
            Cheka cheka=new Cheka();
            cheka.setChekabianhao(b);
            cheka.setChezhubianhao(chezhu.getChezhubianhao());
            cheka.setChekaxinghao("非VIP");
            serviceCheka.Chekainsrt(cheka);
            chezhu.setChekabianhao(b);
            chezhu.setChezhuleixing("非VIP");
            serviceChezhu.Chezhuinsert(chezhu);
            Chezhu chezhu1=serviceChezhu.Chezhuquery(chezhu);
            request.getSession().setAttribute("chezhu1s",chezhu1);
            return "zhucechenggong";
        }
        else return "zhuceshibai";
    }
    @RequestMapping(value = "dingdan.html")
    public String Dingdan(HttpServletRequest request){
       request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "dingdan";
    }
@RequestMapping(value = "chuangjiandingdan.html")
    public String chuangjiandingdan(HttpServletRequest request,Cheweifenpei cheweifenpei){
        Chewei chewei=new Chewei();cheweifenpei.setChezhubianhao(yonghubianhao);
        Chezhu chezhu=new Chezhu();cheweifenpei.setChekabianhao(yonghukahao);
        chezhu.setChezhubianhao(yonghubianhao);
        chewei.setCheweibianhao(cheweifenpei.getCheweibianhao());
        Chewei a=serviceChewei.Cheweiquery(chewei);
        Chezhu b=serviceChezhu.Chezhuquery(chezhu);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date= format.format(new Date());
        SimpleDateFormat format1 = new SimpleDateFormat("yyMMHHmmss");
        String date1= format1.format(new Date());
        int c = Integer.valueOf(date1).intValue();
        cheweifenpei.setDingdanhao(c);
        cheweifenpei.setChuangjianshijian(date);
        String x="否";String y="非VIP";
        if(a.getShifouzhanyong().equals(x)&& a.getCheweileixing().equals(y)&&b.getChezhuleixing().equals(y)){
            serviceCheweifenpei.Cheweifenpeiinsert(cheweifenpei);
            chewei.setCheweileixing("非VIP");chewei.setShifouzhanyong("是");serviceChewei.Cheweimodify(chewei);
            Cheka cheka = new Cheka();cheka.setChekabianhao(cheweifenpei.getChekabianhao());cheka.setChekaxinghao("非VIP");
            cheka.setCheweibianhao(cheweifenpei.getCheweibianhao());serviceCheka.Chekamodify(cheka);
            Cheweifenpei cheweifenpei2=new Cheweifenpei();cheweifenpei2.setDingdanhao(cheweifenpei.getDingdanhao());
            Cheweifenpei cheweifenpei1=serviceCheweifenpei.Cheweifenpeiquery(cheweifenpei2);
            request.getSession().setAttribute("cheweifenpei1s",cheweifenpei1);
            return "dingdanchenggong";
        }
        else
        return "dingdanshibai";
}

@RequestMapping(value = "shengjivip.html")
public String shengjivip(HttpServletRequest request){
    request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "shengjivip";
}

    @RequestMapping(value = "shengjichenggong1.html")
    public String shengjichenggong(Chewei chewei){
       // Chewei chewei1 =new Chewei();
        Chewei chewei1=serviceChewei.Cheweiquery(chewei);
        if(chewei1.getShifouzhanyong().equals("否"))
        {chewei1.setCheweileixing("VIP");
        chewei1.setShifouzhanyong("是");chewei1.setCheweibianhao(chewei.getCheweibianhao());
        serviceChewei.Cheweimodify(chewei1);
        Chezhu chezhu1=new Chezhu();
        chezhu1.setChezhubianhao(yonghubianhao);
        Chezhu chezhu2=serviceChezhu.Chezhuquery(chezhu1);
        Cheka cheka=new Cheka();
        cheka.setChekaxinghao("VIP");
        cheka.setCheweibianhao(chewei.getCheweibianhao());
        cheka.setChekabianhao(chezhu2.getChekabianhao());
        serviceCheka.Chekashengji(cheka);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String date= format.format(new Date());
        chezhu2.setChezhuleixing("VIP");chezhu2.setVipshijian(date);
        serviceChezhu.Chezhushengji(chezhu2);
        return "shengjichenggong";}
        return "shengjishibai";
    }
    @RequestMapping(value = "vipdenglu.html")
    public String vipdenglu(){

        return "vipdenglu";
    }
    @RequestMapping(value = "xiugaigerenxinxi.html")
    public String xiugaigerenxinxi(){
        return "xiugaigerenxinxi";
    }
    @RequestMapping(value = "xiugaigerenxinxi1.html")
    public String xiugaigerenxinxi1(){
        return "xiugaigerenxinxi1";
    }
@RequestMapping(value = "xiugaiqueren.html")
    public String xiugaiqueren(HttpServletRequest request,Chezhu chezhu){
        if(chezhu.getMima().equals(yonghumima))
            return "xiugaichezhu";
        else
        return "xiugaishiabi";
}
    @RequestMapping(value = "xiugaiqueren1.html")
    public String xiugaiqueren1(HttpServletRequest request,Chezhu chezhu){
        if(chezhu.getMima().equals(yonghumima))
            return "xiugaichezhu1";
        else
            return "xiugaishiabi1";
    }
@RequestMapping(value = "chenggong.html")
    public String cehnggong(HttpServletRequest request,Chezhu chezhu){
        Chezhu chezhu1=new Chezhu();
        chezhu1.setChezhubianhao(yonghubianhao);
        chezhu1.setChezhuname(chezhu.getChezhuname());chezhu1.setLianxidianhua(chezhu.getLianxidianhua());
        chezhu1.setChepaihao(chezhu.getChepaihao());chezhu1.setMima(chezhu.getMima());
        serviceChezhu.Chezhumodify(chezhu1);
        Chezhu chezhu2=serviceChezhu.Chezhuquery(chezhu1);
        request.getSession().setAttribute("chezhu2s",chezhu2);
        return "chezhuxiugaicehnggong";
}
    @RequestMapping(value = "chenggong1.html")
    public String cehnggong1(HttpServletRequest request,Chezhu chezhu){
        Chezhu chezhu1=new Chezhu();
        chezhu1.setChezhubianhao(yonghubianhao);
        chezhu1.setChezhuname(chezhu.getChezhuname());chezhu1.setLianxidianhua(chezhu.getLianxidianhua());
        chezhu1.setChepaihao(chezhu.getChepaihao());chezhu1.setMima(chezhu.getMima());
        serviceChezhu.Chezhumodify(chezhu1);
        Chezhu chezhu2=serviceChezhu.Chezhuquery(chezhu1);
        request.getSession().setAttribute("chezhu2s",chezhu2);
        return "chezhuxiugaicehnggong1";
    }

    @RequestMapping(value = "shanchuvip.html",method = RequestMethod.GET)
    public String shanchuvip(HttpServletRequest request,@ModelAttribute Chezhu  user  , Model model) throws ParseException {
        List<Chezhu> chezhu=serviceChezhu.Chezhuqueryvip();
        List<Chezhu> chezhus=new ArrayList<>();
        Map<Integer,String> addrMap=new HashMap<Integer, String>();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date= format.format(new Date());
        Chezhu chezhu1=new Chezhu();
        for(int i=0;i<chezhu.size();i++)
        {
            if(shijian(date)-shijian(chezhu.get(i).getVipshijian())>=31536000)
                chezhus.add(chezhu.get(i));
        }
        for (int i=0;i<chezhus.size();i++)
        {System.out.println(chezhus.get(i).toString());
            addrMap.put(i,Integer.toString(chezhus.get(i).chezhubianhao));}
        model.addAttribute("chezhubianhao",addrMap);
        model.addAttribute("chezhu",chezhu1);
        request.getSession().setAttribute("chezhuss",chezhus);
        return "shanchuvip";}

    @RequestMapping(value = "chenggongshanchu.html")
    public String shanchuchenggongvip(Chezhu chezhu){
        System.out.println(chezhu.getChezhubianhao());
        chezhu.setChezhuleixing("非VIP");
        System.out.println(chezhu.getChezhubianhao());
        serviceChezhu.Chezhushengji(chezhu);
        Chezhu chezhu1=new Chezhu();
        chezhu1=serviceChezhu.Chezhuquery(chezhu);
        Cheka cheka =new Cheka() ;
        cheka.setChekabianhao(chezhu1.getChekabianhao());
        cheka.setChekaxinghao("非VIP");
        serviceCheka.Chekashengji1(cheka);
        Chewei chewei=new Chewei();chewei.setCheweibianhao(serviceCheka.Chekaquery(cheka).getCheweibianhao());
        chewei.setCheweileixing("非VIP");chewei.setShifouzhanyong("否");
        serviceChewei.Cheweimodify(chewei);
        return "guanliyuanzhuyemian";}
    @RequestMapping(value = "chakanvip.html")
    public String chakanvip(HttpServletRequest request){
request.getSession().setAttribute("chezhus",serviceChezhu.Chezhuqueryvip());
        return "chakanvip";}
    @RequestMapping(value = "zengjiachewei.html")
    public String zengjiachewei(HttpServletRequest request){
        request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "zengjiachewei";}
        @RequestMapping(value = "cheweitianjia.html")
        public String cheweitianjia(HttpServletRequest request,Chewei chewei) {
        if(serviceChewei.Cheweiquery(chewei)==null)
        {chewei.setShifouzhanyong("否");chewei.setCheweileixing("非VIP");
        serviceChewei.Cheweiinsrt(chewei);
        request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "zengjiachewei";}
        else
            return "tianjiashibai";
        }
        @RequestMapping(value = "tianjiashibai")
        public String tianjiashibai(){return "tianjiashibai";}


    @RequestMapping(value = "shanchuchewei.html")
    public String shanchuchewei(HttpServletRequest request){
        request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "shanchuchewei";}
    @RequestMapping(value = "cheweishanchu.html")
    public String cheweishanchu(HttpServletRequest request,Chewei chewei) {
        if(serviceChewei.Cheweiquery(chewei)==null||serviceChewei.Cheweiquery(chewei).getShifouzhanyong().equals("是"))
            return "shanchucheweishibai";
        else{
        serviceChewei.Cheweidelete(chewei);
        request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "shanchuchewei";
    }}
    @RequestMapping(value = "shanchucheweishibai.html")
    public String cheweicheweishanchu() {
            return "shanchucheweishibai";
        }
    @RequestMapping(value = "chakanchewei.html")
    public String chakanchewei(){return "chakanchewei";}
    @RequestMapping(value = "chakanchewei1.html")
    public String chakanchewei1(HttpServletRequest request,Dongtaichewei dongtaichewei) throws ParseException {
        long x1=shijian(dongtaichewei.getIntime());
        long y1=shijian(dongtaichewei.getOuttime());
        List<Dongtaichewei> xyz1 = new ArrayList<>();
        List<Dongtaichewei> xyz=serviceDongtaichewei.Dongtaicheweiall(dongtaichewei);
        System.out.println(xyz.size());
        for (int i=0;i<xyz.size();i++)
        {
            long x=shijian(xyz.get(i).getIntime());long y=shijian(xyz.get(i).getOuttime());
            if(x>=x1&&y<=y1||x>=x1&&x<y1&&y>=y1||x<=x1&&y<=y1&&y>x1||x<=x1&&y>=y1)
                xyz1.add(xyz.get(i));
        }
        for (int i=0;i<xyz1.size();i++)
            System.out.println(xyz1.get(i).toString());
        request.getSession().setAttribute("dongtaichewweis",xyz1);
        return "chakanchewei";}
    @RequestMapping(value = "vipjinchang.html")
    public String vipjinchang(){return "vipjinchang";}
    @RequestMapping(value = "vipjinchangcaozuo.html")
    public String jinchang1(HttpServletRequest request,Chezhu chezhu){
        int x=serviceChezhu.Chezhuquery(chezhu).getChekabianhao();
        Cheka cheka=new Cheka();cheka.setChekabianhao(x);
        Cheka cheka1=serviceCheka.Chekaquery(cheka);
        if(cheka1.getChekaxinghao().equals("VIP")){
            Dongtaichewei dongtaichewei=new Dongtaichewei();
            dongtaichewei.setCheweihao(cheka1.getCheweibianhao());
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String date= format.format(new Date());
            dongtaichewei.setIntime(date);
            serviceDongtaichewei.Dongtaicheweiinsrt(dongtaichewei);
        return "huanying";}
        return "shibaijinchang";
    }
    @RequestMapping(value = "shibaijinchang.html")
    public String shibaijinchang(){ return "shibaijinchang";}
    @RequestMapping(value = "wangluojinchang.html")
    public String wangluojinchang(){return "wangluojinchang";}
    @RequestMapping(value = "wangluojinchangcaozuo.html")
    public String wangluojinchang1(Cheweifenpei cheweifenpei) throws ParseException {
        Cheweifenpei cheweifenpei1 = serviceCheweifenpei.Cheweifenpeiquery(cheweifenpei);
        String x = cheweifenpei1.getChuangjianshijian();
        long y = shijian(x);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = format.format(new Date());
        long m = shijian(date);
        if (y + 7200 >= m) {
            Dongtaichewei dongtaichewei = new Dongtaichewei();
            dongtaichewei.setCheweihao(cheweifenpei1.getCheweibianhao());
            dongtaichewei.setIntime(date);
            serviceDongtaichewei.Dongtaicheweiinsrt(dongtaichewei);
            return "huanying";
        } else {
            serviceCheweifenpei.Cheweifenpeidelete(cheweifenpei1);
            Chewei chewei=new Chewei();chewei.setCheweibianhao(cheweifenpei1.getCheweibianhao());
            chewei.setShifouzhanyong("否"); chewei.setCheweileixing("非VIP");serviceChewei.Cheweimodify(chewei );
            return "feipeijieshu";
        }
    }
    @RequestMapping(value = "feipeijieshu.html")
    public String feipeijieshu(){return "feipeijieshu";}


    @RequestMapping(value = "linshijinchang.html")
    public String linshijinchang(HttpServletRequest request){
        request.getSession().setAttribute("cheweis",serviceChewei.Cheweiall());
        return "linshijinchang";}
    @RequestMapping(value = "linshijinchangcaozuo.html")
    public String linshijinchang1(Feiwang feiwang){
        Chewei chewei=new Chewei();chewei.setCheweibianhao(feiwang.getCheweihao());
        if(serviceChewei.Cheweiquery(chewei).getShifouzhanyong().equals("否"))
        {
            Chewei chewei1 =new Chewei();chewei1.setCheweibianhao(feiwang.getCheweihao());
            chewei1.setCheweileixing("非VIP"); chewei1.setShifouzhanyong("是");
            serviceChewei.Cheweimodify(chewei1);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String date = format.format(new Date());
            feiwang.setChuangjiantime(date);
            if(serviceFeiwang.Feiwangquery(feiwang)==null)
            serviceFeiwang.Feiwanginsert(feiwang);
            else
                serviceFeiwang.Feiwangmodify1(feiwang);
            Dongtaichewei dongtaichewei=new Dongtaichewei();dongtaichewei.setCheweihao(feiwang.getCheweihao());
            dongtaichewei.setIntime(date);serviceDongtaichewei.Dongtaicheweiinsrt(dongtaichewei);return "huanying";
        }
        else
        return "cheweiyizhanyong1";
    }
@RequestMapping(value = "cheweiyizhanyong1.html")
public String yizhanyong(){
        return "cheweiyizhanyong";
}

    @RequestMapping(value = "vipchuchang.html")
    public String vipchuchang(){ return "vipchuchang";}
    @RequestMapping(value = "vipchuchangcaozuo.html")
    public String chuchang1(Chezhu chezhu){
        Chezhu chezhu1=serviceChezhu.Chezhuquery(chezhu);
        if(chezhu1.getChezhuleixing().equals("VIP"))
        {
            Cheka cheka=new Cheka();cheka.setChekabianhao(chezhu1.getChekabianhao());
            Cheka cheka1=serviceCheka.Chekaquery(cheka);
            Dongtaichewei dongtaichewei=new Dongtaichewei();dongtaichewei.setCheweihao(cheka1.getCheweibianhao());
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String date = format.format(new Date());
            dongtaichewei.setOuttime(date);
            serviceDongtaichewei.Dongtaicheweimodify(dongtaichewei);
            return "xaiciguangling";
        }
        return "shibaiguangling";
    }
    @RequestMapping(value = "xaiciguangling.html")
    public String shibaiguangling1(){return "xaiciguangling";}
    @RequestMapping(value = "shibaiguangling.html")
    public String shibaiguangling(){return "shibaiguangling";}
    @RequestMapping(value = "wangluochuchang.html")
    public String wangluochuchang(){return "wangluochuchang";}
    @RequestMapping(value = "wangluochuchangcaozuo.html")
    public String wangluochuchang1(HttpServletRequest request, Cheweifenpei cheweifenpei) throws ParseException {
        if(serviceCheweifenpei.Cheweifenpeiquery(cheweifenpei)!=null) {
            Cheweifenpei cheweifenpei1 = serviceCheweifenpei.Cheweifenpeiquery(cheweifenpei);
            Chewei chewei=new Chewei();chewei.setCheweibianhao(cheweifenpei1.getCheweibianhao());
            chewei.setShifouzhanyong("否");chewei.setCheweileixing("非VIP");serviceChewei.Cheweimodify(chewei);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String date = format.format(new Date());
            Dongtaichewei dongtaichewei =new Dongtaichewei();
            dongtaichewei.setCheweihao(chewei.getCheweibianhao());
            dongtaichewei.setOuttime(date);
            serviceDongtaichewei.Dongtaicheweimodify(dongtaichewei);
            Dongtaichewei dongtaichewei1=serviceDongtaichewei.Dongtaicheweiquery1(dongtaichewei);
            long x=shijian(date);
            long y=shijian(dongtaichewei1.intime);int xyz=(int)(x-y);
            double sum=xyz*0.01*0.7-20;cheweifenpei1.setFeiyong1(sum);
            serviceCheweifenpei.Cheweifenpei(cheweifenpei1);
            request.getSession().setAttribute("cheweifenpeis",serviceCheweifenpei.Cheweifenpeiquery(cheweifenpei));
            return "fufei";
        }
        return "shibaiguangling";}
    @RequestMapping(value = "linshichuchang.html")
    public String linshichuchang(){return "linshichuchang";}
    @RequestMapping(value = "linshichuchangcaozuo.html")
    public String linshichuchangcaozuo(HttpServletRequest request,Feiwang feiwang) throws ParseException {
        Feiwang feiwang2=new Feiwang(); feiwang2.setChepaihao(feiwang.getChepaihao());
        Feiwang feiwang1=serviceFeiwang.Feiwangquery(feiwang2);
        Chewei chewei=new Chewei();chewei.setCheweibianhao(feiwang1.getCheweihao());
        chewei.setShifouzhanyong("否");chewei.setCheweileixing("非VIP");
        serviceChewei.Cheweimodify(chewei);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = format.format(new Date());
        Dongtaichewei dongtaichewei =new Dongtaichewei();dongtaichewei.setCheweihao(feiwang1.getCheweihao());
        dongtaichewei.setOuttime(date);
        serviceDongtaichewei.Dongtaicheweimodify(dongtaichewei);
        long x=shijian(feiwang1.getChuangjiantime());long y=shijian(date);
        int xyz=(int)(y-x);
        double sum=xyz*0.01;
        feiwang1.setFeiyong2(sum);
        serviceFeiwang.Feiwangmodify(feiwang1);
        request.getSession().setAttribute("feiwangs",serviceFeiwang.Feiwangquery(feiwang));
        return "fufei1";
  }
}
